package safe.yunchexing.com.cloudsafe.login;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import safe.yunchexing.com.cloudsafe.R;
import safe.yunchexing.com.cloudsafe.model.request.TestLoginReq;
import safe.yunchexing.com.cloudsafe.mvp.BaseMVPActivity;
import safe.yunchexing.com.cloudsafe.mvp.IUI;


/**
 * Created by lixiaoming on 16/4/5.
 */
public class LoginActivity extends BaseMVPActivity<LoginPresenter> implements ILoginUI, View.OnClickListener {

    private Button btLogin;//登录按钮

    @Override
    protected IUI getUI() {
        return this;
    }

    @Override
    protected void onCreateExecute(Bundle savedInstanceState) {
        setContentView(R.layout.activity_login);
        btLogin = (Button) findViewById(R.id.btLogin);
        btLogin.setOnClickListener(this);
    }

    @Override
    protected LoginPresenter createPresenter() {
        return new LoginPresenter();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){

            case R.id.btLogin:

                TestLoginReq req = new TestLoginReq();

                req.setUserName("15901038463");
                req.setDeviceId("c33c82ace7590b7a");
                req.setPassword("7c4a8d09ca3762af61e59520943dc26494f8941b");
                req.setDeviceType("0");
                req.setResolutionHeight("960");
                req.setResolutionWidth("540");
                req.setChannel("2");

                getPresenter().login(req);

                break;
        }
    }

    @Override
    public void startMainTabActivity() {
        Toast.makeText(this," 登录成功!",Toast.LENGTH_SHORT).show();
    }
}
